import { defineStore } from 'pinia'
import { StatusEnum } from '@/enums/httpEnum'
import { getReportingList } from '@/api/report'
import { message as Message } from 'ant-design-vue'
import { ReportingListParams } from '@/api/model/reportModel'
import { BasicResponseModel } from '@/api/model/basicModel'

export const useReportStore = defineStore({
  id: 'app-report',
  state: () => ({
    reportingList: <BasicResponseModel>{}
  }),
  getters: {},
  actions: {
    async getReportingList(params: ReportingListParams) {
      const res = await getReportingList(params)
      const { status, message } = res
      if (status === StatusEnum.ERROR) {
        Message.error(message)
      }
      if (status === StatusEnum.SUCCESS) {
        this.reportingList = res
      }
      return this.reportingList // 返回 newValue || oldValue
    }
  }
})
